<?php
/**
 * UserProfileWidget
 *
 * PHP versions 5
 *
 * LICENSE:
 * 
 * This library is free software; you can redistribute it
 * and/or modify it under the terms of the GNU Lesser General
 * Public License as published by the Free Software Foundation;
 * either version 2.1 of the License, or (at your option) any
 * later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * @category  UserProfileWidget
 * @package   BAZALT/UserProfileWidget
 * @author    Vitalii Savchuk <esvit666@gmail.com>
 * @license   http://www.opensource.org/licenses/lgpl-license.php LGPL
 * @version   $Revision: 90 $
 * @link      http://www.php-solves.com/
 */
 
/**
 * UserProfileWidget
 *
 * @category UserProfileWidget
 * @package  BAZALT/UserProfileWidget
 * @author   Vitalii Savchuk <esvit666@gmail.com>
 * @license  http://www.opensource.org/licenses/lgpl-license.php LGPL
 * @version  $Revision: 90 $
 * @link     http://www.php-solves.com/
 */
class UserProfileWidget extends AbstractRouteWidget implements IWebConfig
{
    public function loadWebConfig(SimpleXMLElement $elem)
    {
        $fileExts = (string)$elem->attributes()->fileExts;
        $fileMaxSize = (string)$elem->attributes()->fileMaxSize;
        $uploadDir = (string)$elem->attributes()->uploadDir;

        if ($fileExts) {
            self::$fileExts = $fileExts;
        }

        if ($fileMaxSize) {
            self::$fileMaxSize = $fileMaxSize;
        }
        
        if ($uploadDir) {
            self::$uploadDir = $uploadDir;
        }        
    }

    public function getUser()
    {
        return Authorization::getUser();
    }

    public function runRoute()
    {
        $user = $this->getParam('user');

        Smarty2::Singleton()->assign('profile', $user);
        Smarty2::Singleton()->display('user.profile.tpl');
    }

    public function display()
    {
        $this->view->assign('user', $this->getUser());

        return $this->render('templates/view.tpl');
    }
}